#import "SEGNewMyDoorListModel.h"

@implementation SEGNewMyDoorListModel
+ (NSDictionary *)modelCustomPropertyMapper {
    return @{ @"desc" : @"description"};
}
-(instancetype)init
{
    self = [super init];
    if (self) {
        _desc = @"";
        _buildId = @"";
        _buildName = @"";
        _communityId = @"";
        _deviceType = @"";
        _flag = @"";
        _deviceid = @"";
        _doorType = @"";
        _ssid = @"";
        _doorId = @"";
        _ts = @"";
        _flagName = @"";
        _name = @"";
        _doorIdStr = @"";
        _type = SEGEnumDoorSettingType_Add;
    }
    return self;
}
- (void)encodeWithCoder:(NSCoder *)encoder
{
    unsigned int count = 0;
    objc_property_t *propertes = class_copyPropertyList([self class], &count);
    for (int i=0; i<count; i++) {
        const char *propertyName = property_getName(propertes[i]);
        NSString *name = [NSString stringWithUTF8String:propertyName];
        id value = [self valueForKey:name];
        [encoder encodeObject:(value)?value:@"" forKey:name];
    }
}

- (id)initWithCoder:(NSCoder *)decoder
{
    if (self = [super init]) {
        unsigned int count =0;
        objc_property_t *propertes = class_copyPropertyList([self class], &count);
        for (int i = 0; i < count; i++) {
            const char *propertyName = property_getName(propertes[i]);
            NSString *name = [NSString stringWithUTF8String:propertyName];
            id value = [decoder decodeObjectForKey:name];
            [self setValue:(value)?value:@"" forKey:name];
        }
        
    }
    return self;
}

- (BOOL)isEqual:(id)object {
    if (self == object) {
        return YES;
    }
    if (![object isKindOfClass:[SEGNewMyDoorListModel class]]) {
        return NO;
    }
    return [self isEqualToDoorModel:(SEGNewMyDoorListModel *)object];
}

- (BOOL)isEqualToDoorModel:(SEGNewMyDoorListModel *)doorModel {
    if (!doorModel) {
        return NO;
    }
    if (self.doorId && doorModel.doorId && [self.doorId isEqualToString:doorModel.doorId]) {
        return YES;
    }
    return NO;
}

- (NSString *)description {
    return [NSString stringWithFormat:@"<%@: %p id = %@ name = %@>", [self class], self, self.doorId, self.name];
}

- (NSUInteger)hash {
    return self.doorId.hash;
}

@end

